cmake_minimum_required(VERSION 3.10)

# 查找GTest
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})

# 测试源文件
set(TEST_SOURCES
    database_test.cpp
    ../src/bplus_tree.cpp
    ../src/database.cpp
)

# 生成测试可执行文件
add_executable(database_test ${TEST_SOURCES})

# 包含主代码目录作为头文件搜索路径
target_include_directories(database_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src)

# 链接GTest库和线程库
target_link_libraries(database_test 
    ${GTEST_LIBRARIES} 
    ${GTEST_MAIN_LIBRARIES}
    pthread
)

# 注册测试
add_test(NAME DatabaseTest COMMAND database_test)
